%This is same as the read_ncfiles.m but reads a different set of runs. Basic routines are same
% This reads 153 and 264 level runs

% Ritabrata Thakur, 18 Jan 2022.
function [data,lat,lon,ix,jx,ncpath,XC,YC,RC,time_start,time_end,time_array,z_ip] = read_ncfiles_km_runs(vert_levs,MMP_number,run_no) 

basepath = <path to 153 and 264 level runs>;

%% I do not need section 109 because I already have these results from read_ncfiles.m

%% section for 153 level
if (vert_levs == 153)
if (MMP_number == 1)
 if (run_no == 1)   
    ncpath = [basepath 'mmp_location/' 'lev_153_back_on_run_mmp1_loc' '.nc'];
 end
 if (run_no == 2)
    ncpath = [basepath 'mmp_location/' 'lev_153_back_off_run_mmp1_loc' '.nc'];
 end
 lat = 25;
 lon = 195;
 ix = 90:91; %x-location of the model output 
 jx = 87:88; %y-location of the model output
  % reading variables
data.temp = ncread(ncpath, 'T', [1 1 1 1], [Inf Inf Inf 1765]); 
data.salt = ncread(ncpath, 'S', [1 1 1 1], [Inf Inf Inf 1765]); 
data.U = ncread(ncpath, 'U', [1 1 1 1], [Inf Inf Inf 1765]);    
data.V = ncread(ncpath, 'V', [1 1 1 1], [Inf Inf Inf 1765]);  
data.W = ncread(ncpath, 'W', [1 1 1 1], [Inf Inf Inf 1765]); 
% you have to put here the path to the grids
gridx_name = 
gridy_name = 
gridz_name = 
XC = rdmds(gridx_name);
YC = rdmds(gridy_name);
RC = rdmds(gridz_name);
time_array = linspace(1, length(data.U(1,1,1,:)), length(data.U(1,1,1,:)));
time_start = time_array(1);
time_end   = time_array(end);
z_ip = RC;
end
% for MMP3
if (MMP_number == 3)    
 if (run_no == 1)   
    ncpath = [basepath 'mmp3_location/' 'lev_153_back_on_run_mmp3_loc' '.nc'];
 end
 if (run_no == 2)
  ncpath = [basepath 'mmp3_location/' 'lev_153_back_off_run_mmp3_loc' '.nc'];
 end
 lat = 29;
 lon = 196.5;
 ix = 168:169; %x-location of the model output 
 jx = 288:289; %y-location of the model output
  % reading variables
data.temp = ncread(ncpath, 'T', [1 1 1 1], [Inf Inf Inf 1765]); 
data.salt = ncread(ncpath, 'S', [1 1 1 1], [Inf Inf Inf 1765]); 
data.U = ncread(ncpath, 'U', [1 1 1 1], [Inf Inf Inf 1765]);    
data.V = ncread(ncpath, 'V', [1 1 1 1], [Inf Inf Inf 1765]);  
data.W = ncread(ncpath, 'W', [1 1 1 1], [Inf Inf Inf 1765]); 
% you have to put here the path to the grids
gridx_name = 
gridy_name = 
gridz_name = 
XC = rdmds(gridx_name);
YC = rdmds(gridy_name);
RC = rdmds(gridz_name);
time_array = linspace(1, length(data.U(1,1,1,:)), length(data.U(1,1,1,:)));
time_start = time_array(1);
time_end   = time_array(end);
z_ip = RC;
end
% for MP4
if (MMP_number == 4)
 if (run_no == 1)   
  ncpath = [basepath 'mmp4_location/' 'lev_153_back_on_run_mmp4_loc' '.nc'];
 end
 if (run_no == 2)
  ncpath = [basepath 'mmp4_location/' 'lev_153_back_off_run_mmp4_loc' '.nc'];   
 end
 lat = 30;
 lon = 197;
 ix = 195:196; %x-location of the model output 
 jx = 360:361; %y-location of the model output
  % reading variables
data.temp = ncread(ncpath, 'T', [1 1 1 1], [Inf Inf Inf 1765]); 
data.salt = ncread(ncpath, 'S', [1 1 1 1], [Inf Inf Inf 1765]); 
data.U = ncread(ncpath, 'U', [1 1 1 1], [Inf Inf Inf 1765]);    
data.V = ncread(ncpath, 'V', [1 1 1 1], [Inf Inf Inf 1765]);  
data.W = ncread(ncpath, 'W', [1 1 1 1], [Inf Inf Inf 1765]); 
% you have to put here the path to the grids
gridx_name = 
gridy_name = 
gridz_name = 
XC = rdmds(gridx_name);
YC = rdmds(gridy_name);
RC = rdmds(gridz_name);
time_array = linspace(1, length(data.U(1,1,1,:)), length(data.U(1,1,1,:)));
time_start = time_array(1);
time_end   = time_array(end);
z_ip = RC;
end
end

%% section for 264 level
if (vert_levs == 264)
if (MMP_number == 1)
 if (run_no == 3)   
    ncpath = [basepath 'mmp_location/' 'lev_264_back_on_run_mmp1_loc' '.nc'];
 end
 if (run_no == 4)
    ncpath = [basepath 'mmp_location/' 'lev_264_back_off_run_mmp1_loc' '.nc'];
 end
 lat = 25;
 lon = 195;
 ix = 90:91; %x-location of the model output 
 jx = 87:88; %y-location of the model output
  % reading variables
data.temp = ncread(ncpath, 'T', [1 1 1 1], [Inf Inf Inf 1765]); 
data.salt = ncread(ncpath, 'S', [1 1 1 1], [Inf Inf Inf 1765]); 
data.U = ncread(ncpath, 'U', [1 1 1 1], [Inf Inf Inf 1765]);    
data.V = ncread(ncpath, 'V', [1 1 1 1], [Inf Inf Inf 1765]);  
data.W = ncread(ncpath, 'W', [1 1 1 1], [Inf Inf Inf 1765]); 
% you have to put here the path to the grids
gridx_name = 
gridy_name = 
gridz_name = 
XC = rdmds(gridx_name);
YC = rdmds(gridy_name);
RC = rdmds(gridz_name);
time_array = linspace(1, length(data.U(1,1,1,:)), length(data.U(1,1,1,:)));
time_start = time_array(1);
time_end   = time_array(end);
z_ip = RC;
end
% for MMP3
if (MMP_number == 3)    
 if (run_no == 3)   
    ncpath = [basepath 'mmp3_location/' 'lev_264_back_on_run_mmp3_loc' '.nc'];
 end
 if (run_no == 4)
    ncpath = [basepath 'mmp3_location/' 'lev_264_back_off_run_mmp3_loc' '.nc'];
 end
 lat = 29;
 lon = 196.5;
 ix = 168:169; %x-location of the model output 
 jx = 288:289; %y-location of the model output
  % reading variables
data.temp = ncread(ncpath, 'T', [1 1 1 1], [Inf Inf Inf 1765]); 
data.salt = ncread(ncpath, 'S', [1 1 1 1], [Inf Inf Inf 1765]); 
data.U = ncread(ncpath, 'U', [1 1 1 1], [Inf Inf Inf 1765]);    
data.V = ncread(ncpath, 'V', [1 1 1 1], [Inf Inf Inf 1765]);  
data.W = ncread(ncpath, 'W', [1 1 1 1], [Inf Inf Inf 1765]); 
% you have to put here the path to the grids
gridx_name = 
gridy_name =
gridz_name = 
XC = rdmds(gridx_name);
YC = rdmds(gridy_name);
RC = rdmds(gridz_name);
time_array = linspace(1, length(data.U(1,1,1,:)), length(data.U(1,1,1,:)));
time_start = time_array(1);
time_end   = time_array(end);
z_ip = RC;
end
% for MP4
if (MMP_number == 4)
 if (run_no == 3)   
  ncpath = [basepath 'mmp4_location/' 'lev_264_back_on_run_mmp4_loc' '.nc'];
 end
 if (run_no == 4)
  ncpath = [basepath 'mmp4_location/' 'lev_264_back_off_run_mmp4_loc' '.nc'];   
 end
 lat = 30;
 lon = 197;
 ix = 195:196; %x-location of the model output 
 jx = 360:361; %y-location of the model output
  % reading variables
data.temp = ncread(ncpath, 'T', [1 1 1 1], [Inf Inf Inf 1765]); 
data.salt = ncread(ncpath, 'S', [1 1 1 1], [Inf Inf Inf 1765]); 
data.U = ncread(ncpath, 'U', [1 1 1 1], [Inf Inf Inf 1765]);    
data.V = ncread(ncpath, 'V', [1 1 1 1], [Inf Inf Inf 1765]);  
data.W = ncread(ncpath, 'W', [1 1 1 1], [Inf Inf Inf 1765]); 
% you have to put here the path to the grids
gridx_name = 
gridy_name = 
gridz_name = 
XC = rdmds(gridx_name);
YC = rdmds(gridy_name);
RC = rdmds(gridz_name);
time_array = linspace(1, length(data.U(1,1,1,:)), length(data.U(1,1,1,:)));
time_start = time_array(1);
time_end   = time_array(end);
z_ip = RC;
end
end
